
package com.booking.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.booking.utils.InterfaceHelper.GPSHelper;

/**
 * @author iholub May 28, 2013
 */
public class MapFragment extends BasicFragment {
    // private GoogleMap mGoogleMap;
    private GPSHelper mGPSHelper;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        // Context applicationContext = getActivity().getApplicationContext();
        // View view = inflater.inflate(R.layout.layout_map, container, false);
        // mGoogleMap = ((SupportMapFragment)
        // getFragmentManager().findFragmentById(R.id.map)).getMap();
        //
        // mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        // mGoogleMap.setMyLocationEnabled(true);
        //
        // double latitude =
        // PreferenceHelper.getSavedLatitude(applicationContext);
        // double longitude =
        // PreferenceHelper.getSavedLongitude(applicationContext);
        // float zoom = PreferenceHelper.getSavedZoom(applicationContext);
        //
        // CameraUpdate center =
        // CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude));
        // CameraUpdate zoomLevel = CameraUpdateFactory.zoomTo(zoom);
        //
        // mGoogleMap.moveCamera(center);
        // mGoogleMap.animateCamera(zoomLevel);
        //
        // List<RestaurantEntity> list = RestUtil.getRestaurantList();
        //
        // for (RestaurantEntity restaurantEntity : list) {
        // mGoogleMap.addMarker(new MarkerOptions().position(
        // new LatLng(restaurantEntity.getLatitude(),
        // restaurantEntity.getLongitude())).title(
        // restaurantEntity.getName()).snippet(restaurantEntity.getSnippet()));
        // }

        return null;
    }

    @Override
    public void updateData() {

    }

    @Override
    public FragmentType getFragmentType() {
        return FragmentType.MAP;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (getActivity() == null) {
            return;
        }

        // Context applicationContext = getActivity().getApplicationContext();
        // SupportMapFragment f = (SupportMapFragment)
        // getFragmentManager().findFragmentById(R.id.map);
        // if (f != null)
        // getFragmentManager().beginTransaction().remove(f).commit();
        //
        // CameraPosition cameraPosition = mGoogleMap.getCameraPosition();
        //
        // PreferenceHelper.setSavedLatitude(applicationContext,
        // cameraPosition.target.latitude);
        // PreferenceHelper.setSavedLongitude(applicationContext,
        // cameraPosition.target.longitude);
        // PreferenceHelper.setSavedZoom(applicationContext,
        // cameraPosition.zoom);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            mGPSHelper = (GPSHelper) activity;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mGPSHelper = null;
    }
}
